<?php
/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/1/9
 * Time: 12:05
 */

namespace App\Models;

/**
 * Class DeclaimerUserRecord
 * @property integer user_wx_id
 * @property string content
 * @property string record_url
 * @property string title
 * @property string avatar
 * @property string type
 * @property string view_count
 */
class DeclaimerUserRecord extends ApplicationModel
{
    protected $fillable = [
        'user_wx_id',
        'content',
        'record_url',
        'title',
        'avatar',
        'type',
        'view_count',
        'user_name',
        'author',
    ];

    public function userLikes()
    {
        return $this->hasMany(DeclaimerUserLike::class, 'record_id');
    }

    public function up_count()
    {
        return $this->userLikes()->where('type', 1)->count();
    }

    public function down_count()
    {
        return $this->userLikes()->where('type', 2)->count();
    }

}
